﻿using System;
using System.Collections.Generic;
using System.Text;

using HyEduOnline.Entities;
using HyEduOnline.Data;
namespace HyEduOnline.Server.Admin
{
	/// <summary>
	///		此用于处理表对象 'tb_Sys_User' 
	/// </summary>
	/// <remarks>
	/// 	此结构由代码由TMS使用代码生成器书写生成，请不要直接修改.
	///注意:此代码可能和同名的视图生成一个完整对象
	/// </remarks>
	

	
	public partial class SysUserBaseDAO
	{
		
	#region 表生成代码
		protected int TotalCount = -1;
		
		
		/// <summary>
       
		
		/// <summary>
        /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbSysUser> GetAll()
        {
            return DataRepository.Provider.TbSysUserProvider.GetAll();
        }

		/// <summary>
        /// 通过id来取对象
        /// </summary>
        /// <param name="id">对象的ID</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public TbSysUser GetByID(int id)
        {
            return DataRepository.Provider.TbSysUserProvider.GetById(id);
        }

        /// <summary>
        /// 条件查询分页
        /// </summary>
        /// <param name="whereClause">条件</param>
        /// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbSysUser> GetByPage(string whereClause, int startRowIndex, int maximumRows)
        {

            return DataRepository.Provider.TbSysUserProvider.GetPaged(whereClause, "ID", (int)startRowIndex / maximumRows, maximumRows, out TotalCount);

        }
		
		 /// <summary>
        ///支持Ext的分页查询,表
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbSysUser>  GetByPage(string whereClause, int start, int limit, string sort, string dir, out int count)
        {
            string sOrder = "";
            if (! String.IsNullOrEmpty(sort ) && sort.ToUpper() != "ID")
            {
                sOrder = sort.Insert(1, "_") + " " + dir;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + " " + dir;
            }
			
            return DataRepository.Provider.TbSysUserProvider.GetPaged(whereClause, sOrder, (int)start / limit, limit, out count);
        }
		
		
		
        /// <summary>
        /// 分页查询计数
        /// </summary>
        /// <param name="whereClause">查询调价</param>
		/// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public int GetCount(string whereClause, int startRowIndex, int maximumRows)
        {
            if (TotalCount != -1)
            {
                return TotalCount;
            }
            else
            {
                DataRepository.Provider.TbSysUserProvider.GetTotalItems(whereClause, out TotalCount);
                return TotalCount;
            }
        }
		
		
		
		
		/// <summary>
        /// 更新对象，传入的是一个对象
        /// </summary>
        /// <param name="item">需要更新的对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, true)]
        public bool Update(TbSysUser item)
        {
            return DataRepository.Provider.TbSysUserProvider.Update(item);
        }
		
		/// <summary>
        /// 更新对象，传入的是一个Tlist对象
        /// </summary>
        /// <param name="items">需要更新的TList对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public int Update(TList<TbSysUser> items)
        {
            return DataRepository.Provider.TbSysUserProvider.Update(items);
        }
		
		
		
		/// <summary>
        /// 更新对象，传入的是此对象的多个属性，属性个数为  34
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public bool Update(
		System.String SUserName, System.String SPassword, 
			System.DateTime? TCreateDate, System.DateTime? TLastLoginDate, System.String SCip, System.String SLip, 
			System.String STrueName, System.String SAddr, System.Int32? IPart, System.Int32? IState, 
			System.String SPro, System.DateTime? DBirth, System.String SNational, System.String SPhone, 
			System.String SFax, System.String SIdCard, System.String SColleage, System.DateTime? DJoinTime, 
			System.String SImg, System.String SSignImg, System.Int32? IScore, System.Int32? IPostRecord, 
			System.Int32? ILevel, System.Int32? ITmp1, System.Int32? ITmp2, System.String STmp1, 
			System.String STmp2, System.String SMem, System.Int32? ISex, System.String SIntroduce, 
			System.String SWorkplace, System.String SEmail, System.Int32? IShowPosition, System.Int32? ISort, 
			System.Int32 Id
		)
        {
			
			TbSysUser item =new TbSysUser();
			
			
			

			item.SUserName = SUserName;
			item.SPassword = SPassword;
			item.TCreateDate = TCreateDate;
			item.TLastLoginDate = TLastLoginDate;
			item.SCip = SCip;
			item.SLip = SLip;
			item.STrueName = STrueName;
			item.SAddr = SAddr;
			item.IPart = IPart;
			item.IState = IState;
			item.SPro = SPro;
			item.DBirth = DBirth;
			item.SNational = SNational;
			item.SPhone = SPhone;
			item.SFax = SFax;
			item.SIdCard = SIdCard;
			item.SColleage = SColleage;
			item.DJoinTime = DJoinTime;
			item.SImg = SImg;
			item.SSignImg = SSignImg;
			item.IScore = IScore;
			item.IPostRecord = IPostRecord;
			item.ILevel = ILevel;
			item.ITmp1 = ITmp1;
			item.ITmp2 = ITmp2;
			item.STmp1 = STmp1;
			item.STmp2 = STmp2;
			item.SMem = SMem;
			item.ISex = ISex;
			item.SIntroduce = SIntroduce;
			item.SWorkplace = SWorkplace;
			item.SEmail = SEmail;
			item.IShowPosition = IShowPosition;
			item.ISort = ISort;
			
			
			item.Id = Id;
			
            return DataRepository.Provider.TbSysUserProvider.Update(item);
        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public int Del(string ids)
        {
		
			TList<TbSysUser> tmpList= GetByPage("id in ("+ids+")",0,int.MaxValue);
			

            return Del(tmpList);

        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public bool Del(int id)
        {

            return DataRepository.Provider.TbSysUserProvider.Delete(id);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="item">对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public bool Del(TbSysUser item)
        {

            return DataRepository.Provider.TbSysUserProvider.Delete(item);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="items">需删除的TList对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public int Del(TList<TbSysUser> items)
        {

            return DataRepository.Provider.TbSysUserProvider.Delete(items);

        }
		
		
		/// <summary>
        /// 插入一个对象
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public bool Insert(TbSysUser item)
        {
            return DataRepository.Provider.TbSysUserProvider.Insert(item);
        }
		
		/// <summary>
        /// 插入一个TList对象
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, false)]
        public int Insert(TList<TbSysUser> items)
        {
            return DataRepository.Provider.TbSysUserProvider.Insert(items);
        }
        
		/// <summary>
        /// 更具条件查找
        /// </summary>
        /// <param name="whereClause">需要查找的条件</param>
        /// <returns>TList对象</returns>
        public TList<TbSysUser> GetByCondition(string whereClause)
        {
            return DataRepository.Provider.TbSysUserProvider.Find(whereClause);
        }
		
		


#endregion 表生成代码

#region 兼容代码



		 /// <summary>
        ///兼容查询
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		
        public  TList<TbSysUser>  getByPageDataBase( int start, int limit, string sort,string whereClause, out int count)
        {
		///(0, 10000, "I_Level ASC,I_Group ASC,ID ASC", "I_Type=1 and id<>1", out count);
            string sOrder = "";
            string[] sortTmps=sort.Split(' ');

            if (!String.IsNullOrEmpty(sort) && sortTmps[0].ToUpper() != "ID")
            {

                sOrder = sort.Insert(1, "_") ;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + "" ;
            }
			
            return DataRepository.Provider.TbSysUserProvider.GetPaged(whereClause, sOrder, start , limit, out count);
        }


 /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbSysUser> findAll()
        {
            return DataRepository.Provider.TbSysUserProvider.GetAll();
        }
		

		 public  TList<TbSysUser> findByProperty(String propertyName, Object value)
        {
            TList<TbSysUser> tmpList = new TList<TbSysUser>();
            try
            {

                string whereC = "";
				 string FirC=propertyName.Substring(0,1);
                if (FirC != "I" || FirC != "F")
                {
                
                    value="'"+value.ToString()+"'";
                }
				
                if (!String.IsNullOrEmpty(propertyName) && propertyName.ToUpper() != "ID")
                {
                    whereC = propertyName.Insert(1, "_") + "= " + value.ToString();
                }
                else
                {
                    whereC = propertyName + "= " + value.ToString();
                }

              
                tmpList = GetByPage(whereC,0,int.MaxValue);
                return tmpList;
            }
            catch (Exception re)
            {
                throw re;
            }
        }//end for findByProperty
		
		
		
		  /*
       *get the Object through SUserName
       */
	public IList<TbSysUser> findBySUserName(Object _SUserName)
        {
            return findByProperty("SUserName",_SUserName);
         }
		
		
		  /*
       *get the Object through SPassword
       */
	public IList<TbSysUser> findBySPassword(Object _SPassword)
        {
            return findByProperty("SPassword",_SPassword);
         }
		
		
		  /*
       *get the Object through TCreateDate
       */
	public IList<TbSysUser> findByTCreateDate(Object _TCreateDate)
        {
            return findByProperty("TCreateDate",_TCreateDate);
         }
		
		
		  /*
       *get the Object through TLastLoginDate
       */
	public IList<TbSysUser> findByTLastLoginDate(Object _TLastLoginDate)
        {
            return findByProperty("TLastLoginDate",_TLastLoginDate);
         }
		
		
		  /*
       *get the Object through SCip
       */
	public IList<TbSysUser> findBySCip(Object _SCip)
        {
            return findByProperty("SCip",_SCip);
         }
		
		
		  /*
       *get the Object through SLip
       */
	public IList<TbSysUser> findBySLip(Object _SLip)
        {
            return findByProperty("SLip",_SLip);
         }
		
		
		  /*
       *get the Object through STrueName
       */
	public IList<TbSysUser> findBySTrueName(Object _STrueName)
        {
            return findByProperty("STrueName",_STrueName);
         }
		
		
		  /*
       *get the Object through SAddr
       */
	public IList<TbSysUser> findBySAddr(Object _SAddr)
        {
            return findByProperty("SAddr",_SAddr);
         }
		
		
		  /*
       *get the Object through IPart
       */
	public IList<TbSysUser> findByIPart(Object _IPart)
        {
            return findByProperty("IPart",_IPart);
         }
		
		
		  /*
       *get the Object through IState
       */
	public IList<TbSysUser> findByIState(Object _IState)
        {
            return findByProperty("IState",_IState);
         }
		
		
		  /*
       *get the Object through SPro
       */
	public IList<TbSysUser> findBySPro(Object _SPro)
        {
            return findByProperty("SPro",_SPro);
         }
		
		
		  /*
       *get the Object through DBirth
       */
	public IList<TbSysUser> findByDBirth(Object _DBirth)
        {
            return findByProperty("DBirth",_DBirth);
         }
		
		
		  /*
       *get the Object through SNational
       */
	public IList<TbSysUser> findBySNational(Object _SNational)
        {
            return findByProperty("SNational",_SNational);
         }
		
		
		  /*
       *get the Object through SPhone
       */
	public IList<TbSysUser> findBySPhone(Object _SPhone)
        {
            return findByProperty("SPhone",_SPhone);
         }
		
		
		  /*
       *get the Object through SFax
       */
	public IList<TbSysUser> findBySFax(Object _SFax)
        {
            return findByProperty("SFax",_SFax);
         }
		
		
		  /*
       *get the Object through SIdCard
       */
	public IList<TbSysUser> findBySIdCard(Object _SIdCard)
        {
            return findByProperty("SIdCard",_SIdCard);
         }
		
		
		  /*
       *get the Object through SColleage
       */
	public IList<TbSysUser> findBySColleage(Object _SColleage)
        {
            return findByProperty("SColleage",_SColleage);
         }
		
		
		  /*
       *get the Object through DJoinTime
       */
	public IList<TbSysUser> findByDJoinTime(Object _DJoinTime)
        {
            return findByProperty("DJoinTime",_DJoinTime);
         }
		
		
		  /*
       *get the Object through SImg
       */
	public IList<TbSysUser> findBySImg(Object _SImg)
        {
            return findByProperty("SImg",_SImg);
         }
		
		
		  /*
       *get the Object through SSignImg
       */
	public IList<TbSysUser> findBySSignImg(Object _SSignImg)
        {
            return findByProperty("SSignImg",_SSignImg);
         }
		
		
		  /*
       *get the Object through IScore
       */
	public IList<TbSysUser> findByIScore(Object _IScore)
        {
            return findByProperty("IScore",_IScore);
         }
		
		
		  /*
       *get the Object through IPostRecord
       */
	public IList<TbSysUser> findByIPostRecord(Object _IPostRecord)
        {
            return findByProperty("IPostRecord",_IPostRecord);
         }
		
		
		  /*
       *get the Object through ILevel
       */
	public IList<TbSysUser> findByILevel(Object _ILevel)
        {
            return findByProperty("ILevel",_ILevel);
         }
		
		
		  /*
       *get the Object through ITmp1
       */
	public IList<TbSysUser> findByITmp1(Object _ITmp1)
        {
            return findByProperty("ITmp1",_ITmp1);
         }
		
		
		  /*
       *get the Object through ITmp2
       */
	public IList<TbSysUser> findByITmp2(Object _ITmp2)
        {
            return findByProperty("ITmp2",_ITmp2);
         }
		
		
		  /*
       *get the Object through STmp1
       */
	public IList<TbSysUser> findBySTmp1(Object _STmp1)
        {
            return findByProperty("STmp1",_STmp1);
         }
		
		
		  /*
       *get the Object through STmp2
       */
	public IList<TbSysUser> findBySTmp2(Object _STmp2)
        {
            return findByProperty("STmp2",_STmp2);
         }
		
		
		  /*
       *get the Object through SMem
       */
	public IList<TbSysUser> findBySMem(Object _SMem)
        {
            return findByProperty("SMem",_SMem);
         }
		
		
		  /*
       *get the Object through ISex
       */
	public IList<TbSysUser> findByISex(Object _ISex)
        {
            return findByProperty("ISex",_ISex);
         }
		
		
		  /*
       *get the Object through SIntroduce
       */
	public IList<TbSysUser> findBySIntroduce(Object _SIntroduce)
        {
            return findByProperty("SIntroduce",_SIntroduce);
         }
		
		
		  /*
       *get the Object through SWorkplace
       */
	public IList<TbSysUser> findBySWorkplace(Object _SWorkplace)
        {
            return findByProperty("SWorkplace",_SWorkplace);
         }
		
		
		  /*
       *get the Object through SEmail
       */
	public IList<TbSysUser> findBySEmail(Object _SEmail)
        {
            return findByProperty("SEmail",_SEmail);
         }
		
		
		  /*
       *get the Object through IShowPosition
       */
	public IList<TbSysUser> findByIShowPosition(Object _IShowPosition)
        {
            return findByProperty("IShowPosition",_IShowPosition);
         }
		
		
		  /*
       *get the Object through ISort
       */
	public IList<TbSysUser> findByISort(Object _ISort)
        {
            return findByProperty("ISort",_ISort);
         }
		
		
#endregion 兼容代码
#region 自定义代码


		
#endregion 自定义代码

	}
}